﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Business_Entity;
using DAOFactory;

namespace Business_Logic
{
    public class BLRol
    {
        public int guardaRol(string rol, string desc, Boolean prr, Boolean prm, Boolean pcr, Boolean pcm, Boolean ocr, Boolean ocm, Boolean rec,
        		              Boolean cmr, Boolean cmm, Boolean pvr, Boolean pvm, Boolean fcr, Boolean fcm, Boolean svr, Boolean svm,         		              
        		              Boolean cir, Boolean cim, Boolean emr, Boolean emm, Boolean rea, Boolean rem, Boolean pdr, Boolean pdm, 
        		              Boolean ppr, Boolean ppm, Boolean dpr, Boolean dpm, Boolean usr, Boolean usm, Boolean ror, Boolean rom,
        		              Boolean tir, Boolean tim, Boolean epr, Boolean epm, Boolean srr, Boolean srm, Boolean prn, Boolean dsc, Boolean rvn, Boolean adm, Boolean dmm, Boolean rvr, Boolean ucr, Boolean ucm, Boolean vlr, Boolean vlm)
            
        {
    		
    		DAORol daoRol = new DAORol();
    		
            int result = daoRol.guardaRol(rol, desc);
            
            if ( (result==0) || (result==2) ) return result;
            
            result = daoRol.guardaRolPrivilegios (rol, prr,  prm,  pcr,  pcm,  ocr,  ocm,  rec,
        		               cmr,  cmm,  pvr,  pvm,  fcr,  fcm,  svr,  svm,  
        		               cir,  cim,  emr,  emm,  rea,  rem,  pdr,  pdm,  
        		               ppr,  ppm,  dpr,  dpm,  usr,  usm,  ror,  rom,
        		               tir,  tim, epr, epm, srr, srm, prn, dsc, rvn, adm, dmm, rvr,ucr, ucm, vlr, vlm);
        	return result;
    	}

    	public List<BERol> buscarRol(String rol, String descripcion)
		{	
			return (new DAORol()).buscarRol(rol,descripcion);
		}
    	
    	public int guardaCambio(string rol, string desc, Boolean prr, Boolean prm, Boolean pcr, Boolean pcm, Boolean ocr, Boolean ocm, Boolean rec,
        		              Boolean cmr, Boolean cmm, Boolean pvr, Boolean pvm, Boolean fcr, Boolean fcm, Boolean svr, Boolean svm, 
        		              Boolean cir, Boolean cim, Boolean emr, Boolean emm, Boolean rea, Boolean rem, Boolean pdr, Boolean pdm, 
        		              Boolean ppr, Boolean ppm, Boolean dpr, Boolean dpm, Boolean usr, Boolean usm, Boolean ror, Boolean rom,
        		              Boolean tir, Boolean tim, Boolean epr, Boolean epm, Boolean srr, Boolean srm, Boolean prn, Boolean dsc, Boolean rvn, Boolean adm, Boolean dmm, Boolean rvr, Boolean ucr, Boolean ucm, Boolean vlr, Boolean vlm){
    		
    		
    		int result = 0;
    		DAORol daoRol = new DAORol();
    		
    		result = daoRol.eliminaRolPrivilegios(rol);
    		
    		if (result == 0) return result;
    		
    		return daoRol.guardaRolPrivilegios(rol, prr,  prm,  pcr,  pcm,  ocr,  ocm,  rec,
        		               cmr,  cmm,  pvr,  pvm,  fcr,  fcm,  svr,  svm,  
        		               cir,  cim,  emr,  emm,  rea,  rem,  pdr,  pdm,  
        		               ppr,  ppm,  dpr,  dpm,  usr,  usm,  ror,  rom,  
        		               tir,  tim, epr, epm, srr, srm, prn, dsc, rvn, adm, dmm, rvr,ucr, ucm, vlr, vlm);
    	}
    	
    	public String buscarDescripcion ( String idRol) {
    		return (new DAORol()).buscarDescripcion(idRol);
    	}
    	
    	public bool buscarPrivilegio (String idRol,int i, string ventana, string modulo) {
    		DAORol daoRol = new DAORol();
    		if( daoRol.buscarPrivilegio(idRol,i,ventana,modulo) == 1)
    			return true;
    		else return false;
    	}
    	
    	public int anularRol(string idRol){
    		return (new DAORol ()).anularRol(idRol);
    	}
    	
    	public List<BEPrivilegio> getPrivilegio (string idRol){
    		return (new DAOUsuario()).getPrivilegio(idRol);
    	}
    		
    }


}
